//
//  UILabel+LabelSizeToFit.m
//  XinJiangMall
//
//  Created by Tzyang on 2018/4/3.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "UILabel+LabelSizeToFit.h"

@implementation UILabel (LabelSizeToFit)

/*
 * Label自适应高度
 */
+ (CGFloat)labelWithLabel:(UILabel *)label
         getHeightByWidth:(CGFloat)width
                    title:(NSString *)title
                     font:(UIFont *)font{
    label.frame=CGRectMake(0, 0, width, 0);
    label.text=title;
    label.font=font;
    label.numberOfLines=0;
    [label sizeToFit];
    return label.frame.size.height;
    
}

/*
 * Label自适应宽度
 */
+ (CGFloat)labelWithLabel:(UILabel *)label
        getWidthWithTitle:(NSString *)title
                     font:(UIFont *)font{
    label.frame=CGRectMake(0, 0, 1000, 0);
    label.text = title;
    label.font = font;
    label.numberOfLines=0;
    [label sizeToFit];
    return label.frame.size.width;
    
}

@end
